package com.example.demo1122.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.demo1122.entity.Classstu;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.data.repository.query.Param;
import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author baomidou
 * @since 2023-12-19
 */
@Mapper
public interface ClassstuMapper extends BaseMapper<Classstu> {
    @Insert("INSERT into classstu(classID, studentID) VALUES (#{classID}, #{studentID})")
    int insert(Classstu classstu);
    // ClassstuMapper.java
    @Insert("INSERT INTO classstu (classID, studentID) VALUES (#{classID}, #{studentID})")
    int insert1(@Param("classID") String classID, @Param("studentID") String studentID);
    @Select("SELECT COUNT(*) FROM classstu WHERE classID = #{classID} AND studentID = #{studentID}")
    int countByClassIdAndStudentId(@Param("classID") Integer classID, @Param("studentID") String studentID);


    @Delete("DELETE FROM classstu WHERE classID = #{classID} AND studentID = #{studentID}")
    int deleteByClassIdAndStudentId(@Param("classID") Integer classID, @Param("studentID") String studentID);
    // 在ClassStuMapper.java
    List<String> selectStudentIdsByClassId(@Param("classID") Integer classID);
    List<String> selectClassIdsByStudentID(@Param("studentID") String studentID);
    int countByClassId(Integer classID);
}




